var FU = {};
(function (exports) {
    var Urls = {
        listDataUrl : "/sys/sysUser/list",
        deleteDataUrl : "/sys/sysUser/delete"
    }

    function operateFormatter(value,row,index) {
        var html = [];
        html.push('<a href="javascript:void(0);" onClick="FU.openEditDialog(\''+ row.userId + '\')" class="fa fa-edit" title="编辑"></a>')
        html.push('<a href="javascript:void(0);" onClick="FU.deleteRow(\''+ row.userId + '\')" class="fa fa fa-trash" title="删除"></a>')
        return html.join("&nbsp;")
    }

    /**
     * 新增窗口
     */
    function openAddDialog() {
        EasyUiUtil.openFrameDialog('/pages/sys/user/user_add.html', {}, function (data) {
            EasyUiUtil.reloadDataGrid("#maindatagrid");
        });
    }
    
    /**
     * 编辑功能
     */
    function openEditDialog(id) {
        EasyUiUtil.openFrameDialog('/pages/sys/user/user_add.html', {id: id}, function (data) {
            EasyUiUtil.reloadDataGrid("#maindatagrid");
        });
    }

    /**
     * 删除
     * @param id
     */
    function deleteRow(id) {
        EasyUiUtil.deleteConfirm(function () {
            BaseUtil.doPost(Urls.deleteDataUrl,{userId: id}, function (msg, result) {
                EasyUiUtil.reloadDataGrid("#maindatagrid");
            })
        });
    }

    exports.Urls = Urls;
    exports.operateFormatter = operateFormatter;
    exports.openAddDialog = openAddDialog;
    exports.openEditDialog = openEditDialog;
    exports.deleteRow = deleteRow;
})(FU);